<?php
/***
//自我游订单核销通知
***/
include('/var/www/html/new/d/module/api/function.class.php');
if (!class_exists("go_sql")){
	include("/var/www/html/new/conf/le.je");
	$le=new go_sql();
	$le->connect();
}

$PFT_infunction = new AllFunction();
$PFT_infunction->logfile('5|'.json_encode($_REQUEST),'checkNote');

$order_id = $_REQUEST['order_id'];
$finish_num = $_REQUEST['finish_num'];

if($order_id){
	$str="select pftOrder,tempOrder from all_api_order where apiOrder='$order_id' limit 1";
	$GLOBALS['le']->query($str);
	if($GLOBALS['le']->fetch_assoc()){
		$pftOrder  = $GLOBALS['le']->f('pftOrder');
		$tempOrder  = $GLOBALS['le']->f('tempOrder');
		$pft_order_xml = $PFT_infunction->Select_PFTorder($pftOrder);
		$UUsalerid  = (string)$pft_order_xml->Rec->UUsalerid;
		$UUcode  = (string)$pft_order_xml->Rec->UUcode;
		$chkIns = 499;
		if((int)$pft_order_xml->Rec->UUstatus==2) $chkIns = 498;
		$r = $PFT_infunction->Unified_Check_IN($UUsalerid,$UUcode,date('Y-m-d H:i:s'),$chkIns);
		if($r == 100){
			$selorder = "update all_api_order  set oStatus=1 where pftOrder='$pftOrder' limit 1";
			$GLOBALS['le']->query($selorder);
			$PFT_infunction->logfile('5|'.$pftOrder.'|'.$tempOrder.'|'.$order_id.'|'.$r,"check_s");
			$response = <<<xml
				<root>
					<result>true</result>
					<msg>接收成功</msg>
				</root>
xml;
			echo $response;
			exit;
		}else{
			$PFT_infunction->logfile('5|'.$pftOrder.'|'.$tempOrder.'|'.$order_id.'|'.$r,"check_f");
			$response = <<<xml
			<root>
				<result>false</result>
				<msg>验证失败</msg>
			</root>
xml;
			echo $response;
			exit;
		}
	}
	else{
		$response = <<<xml
			<root>
				<result>false</result>
				<msg>无此订单</msg>
			</root>
xml;
		echo $response;
		exit;
	}
	
}else{
	$response = <<<xml
	<root>
		<result>false</result>
		<msg>请输入有效数据</msg>
	</root>
xml;
	echo $response;
	exit;
}
?>